<template>
	<view class="">
		<u-field label-width='180' @click=gochangepwd() label="设置操作密码" input-align="right" :disabled="true"
			right-icon='arrow-right'>
		</u-field>
		<!-- 输入密码 -->
		<u-keyboard @change="onChange" ref="uKeyboard" v-model="showKeyboard" @backspace="onBackspace" mode="number" :random="true" :dot-enabled="false" :tooltip="false" default="">
			<view style="text-align: center;">
				请输入验证码
			</view>
			<u-message-input mode="box" :maxlength="6" :dot-fill="true" v-model="password" :disabled-keyboard="true" @finish="finish"></u-message-input>
		</u-keyboard>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				showKeyboard: false,//密码输入的显示隐藏
				password: '',//输入的密码
			}
		},
		methods: {
			onBackspace(e) {
				if (this.password.length > 0) {
					this.password = this.password.substring(0, this.password.length - 1);
				}
			},
			onChange(val) {
				if (this.password.length < 6) {
					this.password += val;
				}
			
				if (this.password.length >= 6) {
					this.finish();//封装的结束函数，我是在后续还有请求接口和判断等
				}
			},
			finish() {
				// this.$http('api/user/checkTradePass', {
				//   pass:this.password
				// }).then(res => {
					
				// });
				// this.showKeyboard = false;
			},
			sendCode(){
				this.$http('api/login/sendCode', {
						phone: uni.getStorageSync('phone'),
						type: 3
					}, 'POST').then(res => {
						console.log(res);
					})
			},
			// 操作密码
			gochangepwd() {
				// let _this=this
				// uni.showModal({
				// 	title: '提示',
				// 	content: '向当前手机号发送验证码\n'+uni.getStorageSync('phone') ,
				// 	success: function(res) {
				// 		if (res.confirm) {
				// 			_this.showKeyboard = true;
				// 			_this.password='';//唤醒输入组件时清空密码
				// 			_this.sendCode()
							
							
				// 		} else if (res.cancel) {}
				// 	}
				// });
				
				uni.navigateTo({
					url: "../my/changePwd"
				})
			},
		}
	}
</script>

<style less="less" scoped>
 
</style>
